{% extends 'TopxiaWebBundle:Settings:layout.html.twig' %}

{% block title %}基础信息 - {{ parent() }}{% endblock %}

{% set script_controller = 'settings/profile' %}
{% set side_nav = 'profile' %}

{% block main %}

	{% embed "TopxiaWebBundle:Bootstrap:panel.html.twig" with {class:'panel-col'} %}
		{% block heading %}基础信息{% endblock %}
		{% block body %}
			
			{% if fromCourse %}
			<div class="alert alert-info">设置头衔、自我介绍并保存后，即可开始创建课程。</div>
			{% endif %}

			<form id="user-profile-form" class="form-horizontal" method="post">
				{{ web_macro.flash_messages() }}

					<div class="form-group">
					<label class="col-md-2 control-label" >昵称</label>
						<div class="col-md-7 controls">
						<div class="control-text">
							{{app.user.nickname}} {% if setting('user_partner.nickname_enabled') %} <a href="{{ path('setting_nickname') }}">修改</a> {% endif %}</div>
						</div>
					</div>

					{# <div class="form-group form-iam-group">
						<label class="col-md-2 control-label">我是</label>
						<div class="col-md-7 controls radios">
							<div id="profile_iam">
								<input type="radio" id="profile_iam_0" name="profile[iam]" required="required" value="student" {% if profile.iam == 'student' %}checked="checked"{% endif %}>
								<label for="profile_iam_0" class="required">在校生</label>
								<input type="radio" id="profile_iam_1" name="profile[iam]" required="required" value="notStudent" {% if profile.iam == 'notStudent' %}checked="checked"{% endif %}>
								<label for="profile_iam_1" class="required">非在校生</label></div>
							</div>
					</div> #}

					<div class="form-group">
					<label class="col-md-2 control-label" for="profile_truename">姓名</label>
						<div class="col-md-7 controls">
							<input type="text" id="profile_truename" name="profile[truename]" class="form-control" data-widget-cid="widget-1" data-explain="" value="{{ profile.truename|default('') }}">              
							<div class="help-block" style="display:none;"></div>
						</div>
					</div>

					<div class="help-block approval">
						<label class="col-md-2 control-label" ></label>
							{% if app.user.approvalStatus == 'approving' %}
								<p class="text-primary" > 
									正在实名认证中，管理员会尽快答复您。
								</p>
							{% elseif  app.user.approvalStatus == 'approved' %}
								<p class="text-success" >
									恭喜您，已通过实名认证！
								</p>
							{% elseif  app.user.approvalStatus == 'unapprove' %}
								<p class="text-warning" > 
									您尚未实名认证，<strong><a href="{{ path('setting_approval_submit') }}">点此认证</a>。
									</strong>
								</p>
							{% elseif app.user.approvalStatus == 'approve_fail' %}
								 <p class="text-danger" > 
									实名认证审核尚未通过，请参照通知中的信息，修改后重新<strong><a href="{{ path('setting_approval_submit') }}">认证。</a>
									</strong>
								 </p>
							{% endif %}
					</div>

					<div class="form-group">
						<label class="col-md-2 control-label">性别</label>
						<div class="col-md-7 controls radios">
							<div id="profile_gender">
								<input type="radio" id="profile_gender_0" name="profile[gender]" required="required" value="male" {% if profile.gender == 'male' %}checked="checked"{% endif %}>
								<label for="profile_gender_0" class="required">男</label>
								<input type="radio" id="profile_gender_1" name="profile[gender]" required="required" value="female" {% if profile.gender == 'female' %}checked="checked"{% endif %}>
								<label for="profile_gender_1" class="required">女</label>
							</div>
						</div>
					</div>

					<div class="form-group">
						<label class="col-md-2 control-label" for="profile_idcard">身份证号</label>
						<div class="col-md-7 controls radios">
							<input type="text" id="profile_idcard" name="profile[idcard]" class="form-control" value="{{ profile.idcard|default('') }}">
							<div class="help-block" style="display:none;"></div>
						</div>
					</div>

					<div class="form-group">
						<label for="profile_mobile" class="col-md-2 control-label">手机号码</label>
						<div class="col-md-7 controls">
							<input type="text" id="profile_mobile" name="profile[mobile]" class="form-control" data-widget-cid="widget-5" data-explain="" value="{{ profile.mobile|default('') }}">
							<div class="help-block" style="display:none;"></div>
						</div>
					</div>

					{# <div class="form-group form-forIam-group form-student-group">
						<label class="col-md-2 control-label">学校</label>
						<div class="col-md-7 controls">
							<input type="text" id="profile_school" name="profile[school]" class="form-control" value="{{ profile.school|default('') }}">
							<div class="help-block" style="display:none;"></div>
						</div>
					</div>

					<div class="form-group form-forIam-group form-student-group">
						<label class="col-md-2 control-label">班级</label>
						<div class="col-md-7 controls">
							<input type="text" id="profile_class" name="profile[class]" class="form-control" value="{{ profile.class|default('') }}">
							<div class="help-block" style="display:none;"></div>
						</div>
					</div> #}

					<div class="form-group form-forIam-group form-notStudent-group">
						<label class="col-md-2 control-label">公司</label>
						<div class="col-md-7 controls">
							<input type="text" id="profile_company" name="profile[company]" class="form-control" value="{{ profile.company|default('') }}">
							<div class="help-block" style="display:none;"></div>
						</div>
					</div>

					<div class="form-group form-forIam-group form-notStudent-group">
						<label class="col-md-2 control-label">职业</label>
						<div class="col-md-7 controls">
							<input type="text" id="profile_job" name="profile[job]" class="form-control" value="{{ profile.job|default('') }}">
							<div class="help-block" style="display:none;"></div>
						</div>
					</div>

					<div class="form-group">
						<label class="col-md-2 control-label">头衔</label>
						<div class="col-md-7 controls">
							<input type="text" id="profile_title" name="profile[title]" class="form-control" value="{{ profile.title|default('') }}">
							<div class="help-block" style="display:none;"></div>
						</div>
					</div> 

					<div class="form-group">
						<label class="col-md-2 control-label">个人签名</label>
						<div class="col-md-7 controls">
							<input type="text" id="profile_signature" name="profile[signature]" class="form-control" value="{{ profile.signature|default('') }}">
							<div class="help-block" style="display:none;"></div>
						</div>
					</div>

					<div class="form-group">
						<label class="col-md-2 control-label">自我介绍</label>
						<div class="col-md-7 controls">
							<textarea name="profile[about]" rows="10" id="profile_about" class="form-control">{{ profile.about|default('') }}</textarea>
						</div>
					</div>

					<div class="form-group">
						<label class="col-md-2 control-label">个人主页</label>
						<div class="col-md-7 controls">
							<input type="text" id="profile_site" name="profile[site]" class="form-control" data-widget-cid="widget-4" data-explain="" value="{{ profile.site|default('') }}">
							<div class="help-block" style="display:none;"></div>
						</div>
					</div>

					<div class="form-group">
						<div class="col-md-2 control-label">
							<label for="weibo">微博</label> 
						</div>
						<div class="col-md-7 controls">
							<input type="text" id="weibo" name="profile[weibo]" class="form-control" data-widget-cid="widget-3" data-explain="" value="{{ profile.weibo|default('') }}">
							<div class="help-block" style="display:none;"></div>
						</div>
					</div>

					<div class="form-group">
						<label class="col-md-2 control-label">微信</label>
						<div class="col-md-7 controls">
							<input type="text" id="profile_weixin" name="profile[weixin]" class="form-control" value="{{ profile.weixin|default('') }}">
							<div class="help-block" style="display:none;"></div>
						</div>
					</div>       

					<div class="form-group">
						<label for="profile_qq" class="col-md-2 control-label">QQ</label>
						<div class="col-md-7 controls">
							<input type="text" id="profile_qq" name="profile[qq]" class="form-control" data-widget-cid="widget-2" data-explain="" value="{{ profile.qq|default('') }}">
							<div class="help-block" style="display:none;"></div>
						</div>
					</div>



					{% if fields %}
					<hr>
					{% for field in fields %}
					{% if field.type=="text" %}
					<div class="form-group">
						<label for="{{field.fieldName}}" class="col-md-2 control-label">{{field.title}}</label>
						<div class="col-md-7 controls">
							<textarea id="{{field.fieldName}}" name="profile[{{field.fieldName}}]" class="{{field.type}} form-control">{{ profile[field.fieldName]|default('') }}</textarea>
							<div class="help-block" style="display:none;"></div>
						</div>
					</div>
					{% elseif field.type=="int" %}
					<div class="form-group">
						<label for="{{field.fieldName}}" class="col-md-2 control-label">{{field.title}}</label>
						<div class="col-md-7 controls">
							<input type="text" id="{{field.fieldName}}" placeholder="最大值为9位整数" name="profile[{{field.fieldName}}]" class="{{field.type}} form-control"  value="{{ profile[field.fieldName]|default('') }}">
							<div class="help-block" style="display:none;"></div>
						</div>
					</div>
					{% elseif field.type=="float" %}
					<div class="form-group">
						<label for="{{field.fieldName}}" class="col-md-2 control-label">{{field.title}}</label>
						<div class="col-md-7 controls">
							<input type="text" id="{{field.fieldName}}" placeholder="保留到2位小数" name="profile[{{field.fieldName}}]" class="{{field.type}} form-control"  value="{{ profile[field.fieldName]|default('') }}">
							<div class="help-block" style="display:none;"></div>
						</div>
					</div>
					{% elseif field.type=="date" %}
					<div class="form-group">
						<label for="{{field.fieldName}}" class="col-md-2 control-label">{{field.title}}</label>
						<div class="col-md-7 controls">
							<input type="text" id="{{field.fieldName}}" name="profile[{{field.fieldName}}]" class="{{field.type}} form-control" value="{% if profile[field.fieldName] %}{{profile[field.fieldName]}}{% endif %}">
							<div class="help-block" style="display:none;"></div>
						</div>
					</div>
					{% elseif field.type=="varchar" %}
					<div class="form-group">
						<label for="{{field.fieldName}}" class="col-md-2 control-label">{{field.title}}</label>
						<div class="col-md-7 controls">
							<input type="text" id="{{field.fieldName}}" name="profile[{{field.fieldName}}]" class="form-control" value="{{ profile[field.fieldName]|default('') }}">
							<div class="help-block" style="display:none;"></div>
						</div>
					</div>
					{% endif %}
					{% endfor %}
					{% endif %}

					<div class="row">
						<div class="col-md-7 col-md-offset-2">
							<button id="profile-save-btn" data-submiting-text="正在保存" type="submit" class="btn btn-primary">保存</button>
						</div>
					</div>

					<input type="hidden" name="_csrf_token" value="{{ csrf_token('site') }}">
			</form>

		{% endblock %}
	{% endembed %}
{% endblock %}